//
//  FinancialService.m
//  BTCoin
//
//  Created by Robin on 22/03/2018.
//  Copyright © 2018 Robin. All rights reserved.
//

#import "FinancialService.h"

@implementation FinancialService

DEFINE_SINGLETON_FOR_CLASS(FinancialService)

#pragma mark - 虚拟货币充值
- (void)rechargeBtc:(NSDictionary *)parDict success:(successResponseBlock)successBlock fail:(failResponseBlock)failBlock {
    
    NSString * para = [parDict toHttpUrlPara];
    NSString * urlStr = [NSString stringWithFormat:@"%@/account/rechargeBtc.do?%@",BaseHttpUrl,para];
    
    [BaseService post:urlStr headerDictionay:[[UserInfo sharedUserInfo] getHeaderDic]  timeout:SERVICETIMEOUT success:^(id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil removingNulls:YES ignoreArrays:NO];
        successBlock(dict);
    } fail:^(NSError *error) {
        failBlock(error);
    }];
}

#pragma mark - 虚拟货币提现
- (void)withdrawBtc:(NSDictionary *)parDict success:(successResponseBlock)successBlock fail:(failResponseBlock)failBlock {
    
    NSString * para = [parDict toHttpUrlPara];
    NSString * urlStr = [NSString stringWithFormat:@"%@/account/withdrawBtc.do?%@",BaseHttpUrl,para];
    
    [BaseService post:urlStr headerDictionay:[[UserInfo sharedUserInfo] getHeaderDic]  timeout:SERVICETIMEOUT success:^(id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil removingNulls:YES ignoreArrays:NO];
        successBlock(dict);
    } fail:^(NSError *error) {
        failBlock(error);
    }];
}

#pragma mark - 个人资产
- (void)financialIndex:(successResponseBlock)successBlock fail:(failResponseBlock)failBlock {
    NSString * urlStr = [NSString stringWithFormat:@"%@/financial/index.do",BaseHttpUrl];
    
    [BaseService post:urlStr headerDictionay:[[UserInfo sharedUserInfo] getHeaderDic]  timeout:SERVICETIMEOUT success:^(id responseObject) {
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil removingNulls:YES ignoreArrays:NO];
        successBlock(dict);
    } fail:^(NSError *error) {
        failBlock(error);
    }];
}

@end
